package cn.ylhx.venue.site.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.ylhx.venue.common.web.JsonResult;
import cn.ylhx.venue.common.web.PageObject;
import cn.ylhx.venue.site.entity.Site_Message;
import cn.ylhx.venue.site.service.SiteService;

/**
 * 场馆管理控制器对象
 */
@Controller
@RequestMapping("/project")
public class SiteController {
	@Resource
	private SiteService siteService;
	@RequestMapping("/listUI")
	@RequiresPermissions("product:project:view")
	public String listUI(){
		return "project/project_list";
	}
	@RequestMapping("/editUI")
	@RequiresPermissions("product:project:add")
	public String editUI(){
		return "project/project_edit";
	}
	@RequestMapping("/findPageObjects")
	@ResponseBody
	@RequiresPermissions("product:project:view")
	public JsonResult doFindPageObjects(Site_Message site_message,PageObject pageObject){//pageCurrent
		Map<String,Object> map= siteService.
			findPageObjects(site_message,pageObject);
	    return new JsonResult(map);//state=1,message=ok,data=map
	}
	/**启用禁用*/
	@RequestMapping("/doValidById")
	@ResponseBody
	@RequiresPermissions("product:project:update")
	public JsonResult doValidById(String checkedIds,Integer valid){
		siteService.validById(checkedIds, valid);
		return new JsonResult();//state=1,message=ok;
	}
	/**保存场馆信息*/
	@RequestMapping("/doSaveSite")
	@ResponseBody
	@RequiresPermissions("product:project:add")
	public JsonResult doSaveProject(Site_Message project){
		siteService.saveObject(project);
		return new JsonResult();
	}
	/**查找场馆信息*/
	@RequestMapping("/doFindById")
	@ResponseBody
	@RequiresPermissions("product:project:update")
	public JsonResult doFindSiteById(
			Integer id){
	    Map<String, Object> project=
	    siteService.findObjectById(id);
		return new JsonResult(project);
	}
	/**修改场馆信息*/
	@RequestMapping("/doUpdateSite")
	@ResponseBody
	@RequiresPermissions("product:project:update")
	public JsonResult doUpdateProject(Site_Message site){
		siteService.updateObject(site);
		return new JsonResult();//state=1,message="ok"
	}
	/*获得场馆添加剂修改的jsp*/
	@RequestMapping("/editSite")
	public String editSite(){
		return "project/city_edit";
	}
	/**获得城市的信息，加载ztree*/
	 //加载城市树的节点
    @RequestMapping("/doFindTreeNodes")
	@ResponseBody
    public JsonResult doFindTreeNodes(){
    	List<Map<String,Object>> list=
    			siteService.findTreeNodes();
    	return new JsonResult(list);
    }
	
}




